home *** CD-ROM | disk | FTP | other *** search
- if {[catch {
- # First fix some problems with Tcl 7.4
- if {[info tclversion] < 7.6} {
- set tcl_platform(platform) macintosh
- # Alpha already has these two renamed internally
- # they need their argument packaged as a list!
- ;proc mkdir {dir} {
- oldMkdir [list $dir]
- }
- ;proc rmdir {dir} {
- oldRmdir [list $dir]
- }
- if {[info commands __file] == ""} {
- rename file __file
- ;proc file {cmd args} {
- switch -- $cmd {
- "join" {
- regsub -all "::" [join $args ":"] ":" res
- return $res
- }
- "copy" {eval copyFile $args}
- "rename" {
- if {[catch {eval moveFile $args} err]} {
- if {$err == "An unknown error occured."} {
- # Buggy Alpha moveFile, try our best so move
- # the file anyway. This will lose the resource
- # fork.
- set f_to [lindex $args 1]
- set f_from [lindex $args 0]
- if {[file exists $f_from] && [file isfile $f_from]} {
- set contents [file::readAll $f_from]
- file::writeAll $f_to $contents 1
- removeFile $f_from
- return
- }
- return -code error "Sorry, moveFile has a\
- bug. Please contact the Alpha-D mailing\
- list for help."
- } else {
- return -code error $err
- }
- }
- }
- "delete" {
- set i 0
- while 1 {
- switch -- [lindex $args $i] {
- "-force" {
- incr i
- set force 1
- }
- "--" {
- incr i
- break
- }
- default {
- break
- }
- }
- }
- global file::separator
- foreach f [lrange $args $i end] {
- if {[file isdirectory $f]} {
- if {[info exists force]} {
- rm -r [string trimright $f ${file::separator}]
- } else {
- rmdir $f
- }
- } else {
- removeFile $f
- }
- }
- }
- "mkdir" {eval mkdir $args}
- "volumes" {
- # Thanks to Jon
- return [tclAE::build::resultData 'MACS' core getd ---- {obj {form:indx, want:type(cdis), seld:abso('all '), from:'null'()}} rtyp TEXT]
- }
- "split" {
- return [split [lindex $args 0] :]
- }
- "attributes" {
- switch -- [lindex $args 1] {
- "-readonly" {
- #__file stat [lindex $args 0] r
- if {[llength $args] > 2} {
- # set read-only status
- } else {
- # get read-only status
- return [expr {![__file writable [lindex $args 0]]}]
- }
- }
- default {
- error "file attributes [lindex $args 1] unimplemented"
- }
- }
-
- }
- "nativename" {
- return [lindex $args 0]
- }
- "pathtype" {
- # Not a perfect implementation, but not bad.
- global alpha::noMenusYet
- # We do this nasty hack to avoid loading all the
- # AE code when we rebuild tcl indices on an Alpha
- # upgrade. Frankly I don't think anyone's ever
- # used a relative path with Alpha except when
- # they type 'auto_mkindex .' in the shell.
- if {[info exists alpha::noMenusYet] && ${alpha::noMenusYet}} {
- return "absolute"
- }
- set relative 1
- set path [lindex $args 0]
- foreach volume [file volumes] {
- if {[string first $volume $path] == 0} {
- unset relative
- break
- }
- }
- if {[info exists relative]} {
- return "relative"
- } else {
- return "absolute"
- }
- }
- default {uplevel 1 __file $cmd $args}
- }
- }
- }
- }
- # Startup of Alpha/Alphatk is split into two phases. The first
- # phase initialises the environment (PREFS folder, early prefs, etc),
- # and the second phase continues with loading of packages, menus,
- # etc, and reads in all of the user's ordinary preferences. During
- # the first phase we should avoid interacting with the user, because
- # the gui may not yet be properly created.
- #
- # We split things into two phases so that, for example, the editor
- # can use some of the information gathered in the first phase
- # (especially the early prefs) and use them to control what happens
- # later. For example, the location/type of status bar used can be
- # set from such early preferences.
-
- # First phase:
- # basic initialisation: (works with Alpha 7.2.1 or 8.0 development)
- # (Note that this phase has already happened under Alphatk, and possibly
- # in the future under Alpha 8).
- source [file join $HOME Tcl SystemCode initAlphaTcl.tcl]
-
- # Second phase:
- # do all the more complex stuff:
- source [file join $HOME Tcl SystemCode runAlphaTcl.tcl]
-
- } err]} {
- append alpha::errorLog "\r" $errorInfo
- set errCache $errorInfo
- if {![llength [info commands auto_load]] \
- || (![auto_load dialog::yesno] || ![auto_load dialog::alert])} {
- # This error happened either too early on in a weird way,
- # so that even the auto-loading mechanism doesn't work
- # (and has overwritten the original problem)
- # We just use the cached information.
- set errorInfo $errCache
- alertnote "That was a core startup error. Alpha will probably\
- not function correctly. Press Ok to view the error. Also note\
- that auto-loading seems not to be functioning."
- if {[info tclversion] < 8.0} {
- alertnote [string range $errorInfo 0 250]
- } else {
- alertnote $errorInfo
- }
- } else {
- if {[dialog::yesno -y "View the error" -n "Continue" \
- "That was a core startup error. Alpha will probably\
- not function correctly."]} {
- dialog::alert $errCache
- }
- }
- }
- if {[info exists alpha::errorLog]} {
- catch {
- new -n "* Alpha startup error log *" -info ${alpha::errorLog}
- unset alpha::errorLog
- }
- }
- # call these two procs to sort out the menu enabled state.
- catch {
- menuEnableHook [expr {[win::Current] != ""}]
- requireOpenWindowsHook 2
- }
- message "Initialization Complete"
-